#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <string.h>

//I like Beijing.

void exchange(char* arr)
{
    int n = strlen(arr) - 1;
    int l = n;
    while (l != -2)
    {
        int x = 0;
        while (*(arr + l) != ' ' && l != -1)
        {
            l--;
            x++;
        }
        for (int i = l + 1; i <= l + x; i++)
        {
            printf("%c", arr[i]);
        }
        printf(" ");
        l--;
    }
}

int main()
{
    char arr[100] = { 0 };
    gets_s(arr);
    exchange(arr);
    return 0;
}